package controller

import (
	"api_interface/service"
	"net/http"

	"github.com/gin-gonic/gin"
)

// 举报
type ReportRequest struct {
	Id         int    `json:"id"`
	Type       int    `json:"typ"`
	Reportid   int    `json:"report_id"`
	Reportedid int    `json:"reported_id"`
	Reason     string `json:"reason"`
	Evidence   string `json:"evidence"`
	Cid        int    `json:"cid"`
	Qid        int    `json:"qid"`
	Bid        int    `json:"bid"`
}

func Report() gin.HandlerFunc {
	return func(c *gin.Context) {
		var r ReportRequest
		c.ShouldBindJSON(&r)
		code, msg := service.Report(r.Id, r.Type, r.Reportid, r.Reportedid, r.Reason, r.Evidence, r.Cid, r.Qid, r.Bid)
		if code != 0 {
			c.JSON(http.StatusBadRequest, gin.H{
				"code": code,
				"msg":  msg,
			})
		} else {
			c.JSON(http.StatusOK, gin.H{
				"code": code,
				"msg":  msg,
			})
		}
	}
}
